# excel 查重效果


from openpyxl import load_workbook
from openpyxl.styles import PatternFill


def dem():
    wb = load_workbook('../02.py_excelFile/data01.xlsx')
    sh = wb.active


    index = []  # 存储哪一行是重复数据
    tmp = []    # 没有重复的数据

    for i, c in enumerate(sh['C']):
        if c.value not in tmp:
            tmp.append(c.value)
        else:
            index.append(i)

    fill = PatternFill('solid', fgColor='BBFFFF')
    for i, row in enumerate(sh.rows):
        if i in index:
            for cell in row:
                cell.fill = fill


    wb.save('../02.py_excelFile/14.查找重复数据.xlsx')



if __name__ == '__main__':
    dem()

